package com.vanysoft.framework.result;

import com.vanysoft.framework.utils.JSONResponse;

/**
 * @author yu_chen
 * @date 2018/7/15 18:12
 */
public class ResponseUtil {


    public static JSONResponse success() {

        return new JSONResponse();
    }

    /**
     * 成功的方法
     *
     * @param resultData 结果集
     * @return
     */
    public static JSONResponse success(Object resultData) {

        return new JSONResponse(resultData);
    }

    /**
     * @param errorMsg 错误信息
     * @return
     */
    public static JSONResponse fail(String errorMsg) {

        return new JSONResponse("500", errorMsg);
    }

    /**
     * 操作失败
     *
     * @return
     */
    public static JSONResponse fail() {

        return new JSONResponse("500", "操作失败");
    }


    /**
     * 操作成功或者失败
     *
     * @param isSuccess 是否成功
     */
    public static JSONResponse successOrFail(boolean isSuccess) {

        return isSuccess ? success() : fail();
    }

}
